<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>
<?php use_helper('Form') ?>	
<div class="sf_admin_form">
  <?php echo form_tag_for($form, '@material') ?>
   <table>
   <tr>
		<th colspan="2">
		<center><?php echo submit_tag(__('Сохранить'), array('onClick'=>"var cont2 = nicEditors.findEditor('material_short_content').getContent(); var cont = nicEditors.findEditor('material_content').getContent();\$('material_content').value = cont;\$('material_short_content').value = cont2"))?></center>
		
		<?php 
		$c = new Criteria();
		$c->add(MaterialPeer::PARENT_ID,$form->getObject()->getId());
		$p = MaterialPeer::doSelectOne($c);
		?>
		
		<?php if (sfConfig::get('app_add_personal_page')=='true'):?>
			<?php if($form->getObject()->getId()>0 and $form->getObject()->getTypeId()=='1'):?>
				<div style="float: right">
					<?php if ($p):?>	
					<?php echo link_to(__('Редактировать персональную страницу'),'material/edit?id='.$p->getId())?>	
					<?php else:?>
					 <?php echo link_to(__('Добавить персональную страницу'),'material/show_material_form?no_ajax=true&type=2&from_id='.$material->getId()); ?>
					<?php endif ?>
				</div>
			<?php endif ?>
		<?php endif ?>
					
		</th>
		</tr>
   	
		<?php echo $form ?>	
		
	
		
		
		<tr>
		<th colspan="2">
		<center><?php echo submit_tag(__('Сохранить'), array('onClick'=>"var cont2 = nicEditors.findEditor('material_short_content').getContent(); var cont = nicEditors.findEditor('material_content').getContent();\$('material_content').value = cont;\$('material_short_content').value = cont2"))?></center>			
		</th>
		</tr>
		</table>
  </form>
</div>


